#!/usr/bin/perl

use lib './lib';

# TODO: 
# - master/slave status
# - if you change fields after create things will all messed up

# example graph command:
# rrdtool graph req.png --end 1202197140 --start 1202194500 --height=600    \
#   --width=800 DEF:gets=animal.rrd:get_count:AVERAGE LINE2:gets#ff0000   \
#   DEF:puts=animal.rrd:put_count:AVERAGE LINE2:puts#0000ff   \
#   DEF:scan=animal.rrd:scan_count:AVERAGE LINE2:scan#00ff00  \

use strict;
use warnings;
use DB;
use RRDSet;

my $config = shift (@ARGV);
unless ($config)
{
  $0 =~ /(.*)\.pl/;
  $config = "$1.conf";
}

{
  my $fh;
  local $/ = undef;
  open ($fh, '<'.$config)
    or die "unable to open config ($config) for input\n";
  eval <$fh>;
  die $@ if ($@);
  close ($fh);
}

my $rrdset = RRDSet->new($config);
$rrdset->run;
